package com.geek.javase.wcy04.HomeworMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
 * @author wangchaoyang
 * @desc TODO
 * @date 2025/9/4
 */
public class Map1 {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.print("请输入一组字符串：");
            String input = scanner.nextLine();
            scanner.close();
            Map<Character, Integer> letterCountMap = new HashMap<>();
         //遍历字符串，统计每个字母的出现次数（区分大小写）
            for (int i = 0; i < input.length(); i++) {
                char currentChar = input.charAt(i);
                if (Character.isLetter(currentChar)) {
                    if (letterCountMap.containsKey(currentChar)) {
                        letterCountMap.put(currentChar, letterCountMap.get(currentChar) + 1);
                    } else {
                        letterCountMap.put(currentChar, 1);
                    }
                }
            }
            System.out.println("每个字母（区分大小写）的出现次数：");
            for (Map.Entry<Character, Integer> entry : letterCountMap.entrySet()) {
                System.out.println(entry.getKey() + "：" + entry.getValue() + "次");
            }
        }
    }
